/**
 * 国际化工具
 */
import React from 'react'

export type Language = 'zh-CN' | 'en-US'

export interface I18nConfig {
  locale: Language
  messages: Record<string, Record<string, string>>
}

// 中文语言包
const zhCNMessages: Record<string, string> = {
  // 通用
  'common.save': '保存',
  'common.cancel': '取消',
  'common.delete': '删除',
  'common.edit': '编辑',
  'common.create': '新建',
  'common.search': '搜索',
  'common.reset': '重置',
  'common.confirm': '确认',
  'common.loading': '加载中...',
  'common.success': '成功',
  'common.failed': '失败',
  'common.operation': '操作',
  'common.status': '状态',
  'common.enable': '启用',
  'common.disable': '禁用',
  'common.active': '启用',
  'common.inactive': '禁用',
  'common.visible': '显示',
  'common.hidden': '隐藏',
  'common.id': 'ID',
  'common.refresh': '刷新',
  'common.batchDelete': '批量删除',
  'common.firstPage': '首页',
  'common.lastPage': '末页',
  'common.prevPage': '上一页',
  'common.nextPage': '下一页',
  'common.pageIndicator': '第 {page} 页',
  'common.totalRecords': '共 {count} 条记录',
  'common.yes': '是',
  'common.no': '否',
  'common.unknownError': '未知错误',
  'common.home': '首页',
  
  // 导航
  'nav.dashboard': '数据概览',
  'nav.workplace': '工作台',
  'nav.document': '文档管理',
  'nav.user': '用户中心',
  'nav.system': '系统管理',
  'nav.settings': '系统设置',

  // 侧边栏
  'sidebar.dashboard': '数据看板',
  'sidebar.product': '商品管理',
  'sidebar.productList': '商品列表',
  'sidebar.productCategory': '商品分类',
  'sidebar.productUpload': '批量导入',
  'sidebar.order': '订单管理',
  'sidebar.orderList': '订单列表',
  'sidebar.orderRefund': '退款管理',
  'sidebar.user': '用户管理',
  'sidebar.document': '协同文档',
  'sidebar.docList': '文档列表',
  'sidebar.docCollab': '在线协作',
  'sidebar.statistics': '数据统计',
  'sidebar.salesStats': '销售统计',
  'sidebar.dataExport': '数据导出',
  'sidebar.fileManage': '文件管理',
  'sidebar.fileList': '文件列表',
  'sidebar.favorites': '我的收藏',
  'sidebar.recycleBin': '回收站',
  'sidebar.chat': '即时通讯',
  'sidebar.system': '系统管理',
  'sidebar.roleManage': '角色管理',
  'sidebar.permissionManage': '权限配置',
  'sidebar.menuManage': '菜单管理',
  'sidebar.auditLog': '审计日志',
  'sidebar.settings': '系统设置',
  
  // 系统设置
  'settings.title': '系统设置',
  'settings.subtitle': '配置系统基本参数和功能选项',
  'settings.basic': '基本设置',
  'settings.email': '邮件设置',
  'settings.security': '安全设置',
  'settings.storage': '存储设置',
  'settings.notification': '通知设置',
  'settings.systemName': '系统名称',
  'settings.systemLanguage': '系统语言',
  'settings.systemTimezone': '时区设置',
  'settings.systemDescription': '系统描述',
  'settings.systemLogo': '系统Logo',
  'settings.smtpHost': 'SMTP服务器',
  'settings.smtpPort': 'SMTP端口',
  'settings.smtpUser': 'SMTP用户名',
  'settings.smtpPassword': 'SMTP密码',
  'settings.smtpFrom': '发件人邮箱',
  'settings.smtpSsl': '启用SSL/TLS',
  'settings.securityHelper': '配置密码策略和登录安全选项',
  'settings.defaultSystemName': '通用管理系统',
  'settings.defaultDescription': '企业级管理系统平台',
  'settings.systemNamePlaceholder': '请输入系统名称',
  'settings.systemDescriptionPlaceholder': '请输入系统描述',
  'settings.uploadLogo': '上传Logo',
  'settings.logoTip': '建议尺寸：200x200px，支持 PNG、JPG 格式，最大 2MB',
  'settings.clearLogo': '清除Logo',
  'settings.logoTypeError': '请上传 PNG 或 JPG 格式的图片',
  'settings.logoSizeError': '图片大小不能超过 2MB',
  'settings.logoReadError': '图片读取失败，请重试',
  'settings.emailHelper': '用于发送系统通知邮件、验证邮件等功能',
  'settings.smtpPasswordPlaceholder': '请输入SMTP密码',
  'settings.testConnection': '测试连接',
  'settings.passwordPolicyTitle': '密码策略',
  'settings.loginSecurityTitle': '登录安全',
  'settings.storageTypeLabel': '存储类型',
  'settings.storageLocal': '本地存储',
  'settings.storageOss': '阿里云OSS',
  'settings.storageS3': 'AWS S3',
  'settings.storageQiniu': '七牛云',
  'settings.notificationEmailDesc': '启用系统邮件通知功能',
  'settings.notificationSmsDesc': '启用短信通知功能',
  'settings.notificationPushDesc': '启用浏览器推送通知',
  'settings.saveSuccess': '设置已保存成功！系统名称和Logo已更新到导航栏和浏览器标题',
  'settings.passwordMinLength': '最小密码长度',
  'settings.passwordRequireUppercase': '必须包含大写字母',
  'settings.passwordRequireLowercase': '必须包含小写字母',
  'settings.passwordRequireNumber': '必须包含数字',
  'settings.passwordRequireSpecial': '必须包含特殊字符',
  'settings.loginAttempts': '最大登录尝试次数',
  'settings.sessionTimeout': '会话超时时间（分钟）',
  'settings.twoFactorAuth': '启用双因素认证（2FA）',
  'settings.storageType': '存储类型',
  'settings.storagePath': '存储路径',
  'settings.maxFileSize': '最大文件大小（MB）',
  'settings.emailNotification': '邮件通知',
  'settings.smsNotification': '短信通知',
  'settings.pushNotification': '推送通知',
  
  // 角色管理
  'role.title': '角色管理',
  'role.subtitle': '管理系统角色和权限分配',
  'role.name': '角色名称',
  'role.code': '角色代码',
  'role.description': '角色描述',
  'role.userCount': '用户数',
  'role.permissionCount': '权限数',
  'role.create': '新建角色',
  'role.edit': '编辑角色',
  'role.delete': '删除角色',
  'role.permissions': '权限配置',
  'role.codePlaceholder': '请输入角色编码，例如 admin',
  'role.descriptionPlaceholder': '请输入角色描述',
  'role.wip': 'RBAC 权限系统功能正在开发中，后续将支持角色与权限的完整管理。',
  'role.searchPlaceholder': '搜索角色名称...',
  'role.batchDelete': '批量删除',
  'role.batchDeleteWithCount': '批量删除 ({count})',
  'role.empty': '暂无角色数据',
  'role.table.id': 'ID',
  'role.table.name': '角色名称',
  'role.table.age': '年龄',
  'role.table.gender': '性别',
  'role.table.status': '状态',
  'role.table.createTime': '创建时间',
  'role.table.updateTime': '更新时间',
  'role.table.actions': '操作',
  'role.gender.male': '男',
  'role.gender.female': '女',
  'role.status.enabled': '启用',
  'role.status.disabled': '禁用',
  'role.confirmDelete': '确定要删除这个角色吗？',
  'role.addSuccess': '角色添加成功',
  'role.addFailed': '添加角色失败，请稍后重试',
  'role.updateSuccess': '角色更新成功',
  'role.updateFailed': '更新角色失败，请稍后重试',
  'role.deleteSuccess': '角色删除成功',
  'role.deleteFailed': '删除角色失败，请稍后重试',
  'role.batchDeleteEmpty': '请先选择要删除的角色',
  'role.batchDeleteConfirm': '确定要删除选中的 {count} 个角色吗？',
  'role.batchDeleteSuccess': '批量删除成功',
  'role.batchDeleteFailed': '批量删除失败，请稍后重试',
  'role.namePlaceholder': '请输入角色名称',
  'role.nameRequired': '请填写角色名称',
  'role.agePlaceholder': '请输入年龄',
  'role.ageInvalid': '请输入有效的年龄',
  'role.modal.createTitle': '新增角色',
  'role.modal.editTitle': '编辑角色',

  // 文件管理
  'file.manage.title': '文件管理',
  'file.manage.subtitle': '管理上传的文件（支持大文件切片上传）',

  // 商品模块
  'product.list.title': '商品列表',
  'product.list.subtitle': '管理所有商品信息',
  'product.category.title': '商品分类',
  'product.category.subtitle': '管理商品分类信息',
  'product.upload.title': '批量导入',
  'product.upload.subtitle': '批量导入商品数据（支持大文件上传）',

  // 订单模块
  'order.list.title': '订单列表',
  'order.list.subtitle': '管理所有订单信息',
  'order.list.pageTitle': '订单列表',
  'order.list.pageDescription': '管理所有订单信息',
  'order.list.addOrder': '添加订单',
  'order.list.exportExcel': '导出Excel',
  'order.list.exportImage': '导出图片',
  'order.list.exportWord': '导出Word',
  'order.list.exporting': '导出中...',
  'order.list.exportData': '导出数据',
  'order.list.tabs.all': '全部订单',
  'order.list.tabs.pending': '待处理',
  'order.list.tabs.shipped': '已发货',
  'order.list.tabs.completed': '已完成',
  'order.list.table.orderId': '订单编号',
  'order.list.table.productName': '商品名称',
  'order.list.table.productPrice': '商品价格',
  'order.list.table.quantity': '购买数量',
  'order.list.table.totalPrice': '订单总价',
  'order.list.table.customerName': '客户姓名',
  'order.list.table.customerPhone': '客户电话',
  'order.list.table.address': '收货地址',
  'order.list.table.status': '订单状态',
  'order.list.table.createdAt': '创建时间',
  'order.list.table.actions': '操作',
  'order.list.status.pending': '待处理',
  'order.list.status.shipped': '已发货',
  'order.list.status.completed': '已完成',
  'order.list.status.cancelled': '已取消',
  'order.list.empty': '暂无订单数据',
  'order.list.pagination': '共 {total} 条数据',
  'order.list.modal.title': '添加订单',
  'order.list.modal.product': '选择商品',
  'order.list.modal.productPlaceholder': '请选择商品',
  'order.list.modal.quantity': '购买数量',
  'order.list.modal.quantityPlaceholder': '请输入购买数量',
  'order.list.modal.quantityRequired': '请输入购买数量',
  'order.list.modal.quantityInvalid': '数量必须大于0',
  'order.list.modal.customerName': '客户姓名',
  'order.list.modal.customerNamePlaceholder': '请输入客户姓名',
  'order.list.modal.customerNameRequired': '请输入客户姓名',
  'order.list.modal.customerPhone': '客户电话',
  'order.list.modal.customerPhonePlaceholder': '请输入客户电话',
  'order.list.modal.customerPhoneRequired': '请输入客户电话',
  'order.list.modal.customerPhoneInvalid': '请输入正确的手机号码',
  'order.list.modal.address': '收货地址',
  'order.list.modal.addressPlaceholder': '请输入收货地址',
  'order.list.modal.addressRequired': '请输入收货地址',
  'order.list.modal.ok': '确定',
  'order.list.modal.cancel': '取消',
  'order.list.modal.stock': '库存',
  'order.list.messages.fetchProductsFailed': '获取商品列表失败',
  'order.list.messages.fetchProductsFallback': '{message}，已使用模拟商品数据',
  'order.list.messages.fetchOrdersFailed': '获取订单列表失败，请检查后端服务',
  'order.list.messages.fetchOrdersFallback': '{message}，已使用模拟订单数据',
  'order.list.messages.inventoryInsufficient': '库存不足，当前库存：{stock}',
  'order.list.messages.addSuccess': '订单添加成功',
  'order.list.messages.addFailed': '添加订单失败',
  'order.list.messages.addFailedNetwork': '添加订单失败，请检查网络连接',
  'order.list.messages.statusUpdateSuccess': '订单状态更新成功',
  'order.list.messages.statusUpdateFailed': '更新订单状态失败',
  'order.list.messages.statusUpdateFailedNetwork': '更新订单状态失败，请检查网络连接',
  'order.list.messages.exportExcelSuccess': 'Excel导出成功',
  'order.list.messages.exportExcelFailed': '导出Excel失败',
  'order.list.messages.exportImageSuccess': '图片导出成功',
  'order.list.messages.exportImageFailed': '导出图片失败',
  'order.list.messages.exportWordSuccess': 'Word导出成功',
  'order.list.messages.exportWordFailed': '导出Word失败',
  'order.list.messages.unknownProduct': '未知商品',
  'order.list.messages.generatedAt': '生成时间: {time}',
  'order.list.delete.confirmTitle': '确认删除',
  'order.list.delete.confirmContent': '确定要删除这条订单吗？',
  'order.list.delete.success': '订单删除成功',
  'order.list.delete.failed': '删除订单失败',

  // 退款管理模块
  'order.refund.title': '退款管理',
  'order.refund.subtitle': '管理已取消订单的退款处理',
  'order.refund.refresh': '刷新列表',
  'order.refund.exportExcel': '导出Excel',
  'order.refund.exportImage': '导出图片',
  'order.refund.exportWord': '导出Word',
  'order.refund.exporting': '导出中...',
  'order.refund.exportData': '导出数据',
  'order.refund.tabs.pending': '未处理退款',
  'order.refund.tabs.processed': '已处理退款',
  'order.refund.table.orderId': '订单编号',
  'order.refund.table.productName': '商品名称',
  'order.refund.table.productPrice': '商品价格',
  'order.refund.table.quantity': '购买数量',
  'order.refund.table.totalPrice': '订单总价',
  'order.refund.table.customerName': '客户姓名',
  'order.refund.table.customerPhone': '客户电话',
  'order.refund.table.address': '收货地址',
  'order.refund.table.createdAt': '创建时间',
  'order.refund.table.status': '退款状态',
  'order.refund.table.actions': '操作',
  'order.refund.status.pending': '未处理退款',
  'order.refund.status.processed': '已处理退款',
  'order.refund.status.unprocessedCount': '共 {count} 条未处理退款订单',
  'order.refund.status.processedCount': '共 {count} 条已处理退款订单',
  'order.refund.empty.pending': '暂无未处理退款订单',
  'order.refund.empty.processed': '暂无已处理退款订单',
  'order.refund.actions.processRefund': '处理退款',
  'order.refund.actions.processed': '已处理',
  'order.refund.actions.delete': '删除',
  'order.refund.confirm.title': '确认退款',
  'order.refund.confirm.content': '确定要处理该订单的退款吗？退款后将无法撤销此操作。',
  'order.refund.confirm.ok': '确定',
  'order.refund.confirm.cancel': '取消',
  'order.refund.messages.refundSuccess': '退款处理成功',
  'order.refund.messages.refundFailed': '退款处理失败',
  'order.refund.messages.refundFailedNetwork': '退款处理失败，请检查网络连接',
  'order.refund.messages.fetchFailed': '获取退款订单列表失败',
  'order.refund.messages.deleteSuccess': '订单删除成功',
  'order.refund.messages.deleteFailed': '订单删除失败',
  'order.refund.messages.deleteFailedNetwork': '订单删除失败，请检查网络连接',
  'order.refund.messages.exportExcelSuccess': 'Excel导出成功',
  'order.refund.messages.exportExcelFailed': '导出Excel失败',
  'order.refund.messages.exportImageSuccess': '图片导出成功',
  'order.refund.messages.exportImageFailed': '导出图片失败',
  'order.refund.messages.exportWordSuccess': 'Word导出成功',
  'order.refund.messages.exportWordFailed': '导出Word失败',
  'order.refund.messages.generatedAt': '生成时间: {time}',
  'order.refund.messages.unknownProduct': '未知商品',

  // 统计模块
  'statistics.sales.title': '销售统计',
  'statistics.sales.subtitle': '销售数据分析与统计',
  'statistics.export.title': '数据导出',
  'statistics.export.subtitle': '导出各类数据报表（PDF/Word/Excel）',

  // 文档模块
  'document.list.title': '协同文档',
  'document.list.subtitle': '团队协作文档管理 - 支持商品详情、活动策划、知识库等多场景',
  'document.collab.title': '在线协作编辑器',
  'document.collab.subtitle': '多人实时协作编辑（WebSocket + 冲突解决）',

  // 用户模块
  'user.list.title': '用户管理',
  'user.list.subtitle': '管理电商用户信息和权限',
  
  // 权限管理
  'permission.title': '权限管理',
  'permission.subtitle': '配置系统权限和功能访问控制',
  'permission.name': '权限名称',
  'permission.code': '权限代码',
  'permission.type': '权限类型',
  'permission.group': '权限分组',
  'permission.description': '权限描述',
  'permission.create': '新建权限',
  'permission.edit': '编辑权限',
  'permission.delete': '删除权限',
  'permission.typeMenu': '菜单权限',
  'permission.typeButton': '按钮权限',
  'permission.typeApi': 'API权限',
  'permission.searchPlaceholder': '请输入角色名称',
  'permission.refresh': '刷新',
  'permission.batchDelete': '批量删除',
  'permission.batchDeleteWithCount': '批量删除 ({count})',
  'permission.add': '添加权限',
  'permission.deleteConfirm': '确定要删除这条权限记录吗？',
  'permission.batchDeleteConfirm': '确定要删除选中的 {count} 条权限记录吗？',
  'permission.batchDeleteEmpty': '请选择要删除的权限记录',
  'permission.addSuccess': '权限添加成功',
  'permission.updateSuccess': '权限更新成功',
  'permission.deleteSuccess': '删除成功',
  'permission.deleteFailed': '删除失败: {error}',
  'permission.batchDeleteSuccess': '批量删除成功',
  'permission.batchDeleteFailed': '批量删除失败: {error}',
  'permission.fetchError': '数据加载失败: {error}',
  'permission.operationFailed': '操作失败: {error}',
  'permission.scopePlaceholder': '请输入权限范围，多个权限用逗号分隔',
  'permission.scenePlaceholder': '请输入适用场景',
  'permission.total': '共 {count} 条记录',
  'permission.none': '无权限',
  'permission.validation.roleNameRequired': '角色名称不能为空',
  'permission.validation.scopeRequired': '权限范围不能为空',
  'permission.validation.sceneRequired': '适用场景不能为空',
  'permission.loadingTip': '正在加载权限数据...',
  'permission.table.id': '权限ID',
  'permission.table.roleName': '角色名称',
  'permission.table.scope': '权限范围',
  'permission.table.scene': '适用场景',
  'permission.table.createTime': '创建时间',
  'permission.table.actions': '操作',
  'permission.emptyTitle': '暂无权限数据',
  'permission.emptySubtitle': '目前系统中没有权限记录，点击下方按钮添加新的权限配置。',
  'permission.editAction': '编辑',
  'permission.deleteAction': '删除',
  
  // 菜单管理
  'menu.title': '菜单管理',
  'menu.subtitle': '管理系统菜单结构和权限配置',
  'menu.name': '菜单名称',
  'menu.path': '菜单路径',
  'menu.icon': '菜单图标',
  'menu.sort': '排序',
  'menu.parent': '父级菜单',
  'menu.type': '菜单类型',
  'menu.permission': '权限代码',
  'menu.visible': '显示菜单',
  'menu.create': '新建菜单',
  'menu.edit': '编辑菜单',
  'menu.delete': '删除菜单',
  'menu.addChild': '添加子菜单',
  'menu.add': '添加菜单',
  'menu.export': '导出菜单',
  'menu.batchDelete': '批量删除',
  'menu.batchDeleteWithCount': '批量删除 ({count})',
  'menu.searchPlaceholder': '搜索菜单名称或路径',
  'menu.loading': '加载中...',
  'menu.empty': '暂无菜单数据',
  'menu.total': '共 {count} 条记录',
  'menu.table.id': '菜单ID',
  'menu.table.name': '菜单名称',
  'menu.table.path': '路径',
  'menu.table.parent': '父菜单',
  'menu.table.level': '级别',
  'menu.table.order': '排序',
  'menu.table.hidden': '隐藏',
  'menu.table.status': '状态',
  'menu.table.createTime': '创建时间',
  'menu.table.actions': '操作',
  'menu.boolean.yes': '是',
  'menu.boolean.no': '否',
  'menu.parent.top': '顶级菜单',
  'menu.parent.unknown': '未知父菜单',
  'menu.toggleEnable': '启用',
  'menu.toggleDisable': '禁用',
  'menu.deleteConfirm': '确定要删除这个菜单吗？删除后不可恢复！',
  'menu.deleteSuccess': '菜单删除成功',
  'menu.deleteFailed': '删除菜单失败: {error}',
  'menu.addSuccess': '菜单添加成功',
  'menu.addFailed': '保存菜单失败: {error}',
  'menu.updateSuccess': '菜单更新成功',
  'menu.updateFailed': '保存菜单失败: {error}',
  'menu.toggleSuccess': '菜单状态已切换',
  'menu.toggleFailed': '切换菜单状态失败: {error}',
  'menu.batchDeleteEmpty': '请选择要删除的菜单',
  'menu.batchDeleteConfirm': '确定要删除选中的 {count} 个菜单吗？删除后不可恢复！',
  'menu.batchDeleteSuccess': '批量删除菜单成功',
  'menu.batchDeleteFailed': '批量删除菜单失败: {error}',
  'menu.exportSuccess': '导出菜单数据成功',
  'menu.exportFailed': '导出菜单数据失败: {error}',
  'menu.fetchFailed': '获取菜单列表失败: {error}',
  'menu.searchFailed': '搜索菜单失败: {error}',
  'menu.form.nameLabel': '菜单名称 *',
  'menu.form.pathLabel': '菜单路径 *',
  'menu.form.componentLabel': '组件路径 *',
  'menu.form.iconLabel': '菜单图标',
  'menu.form.parentLabel': '父菜单',
  'menu.form.orderLabel': '排序',
  'menu.form.hiddenLabel': '是否隐藏菜单',
  'menu.form.statusLabel': '状态',
  'menu.form.levelInfo': '当前菜单级别: {level}',
  'menu.form.namePlaceholder': '请输入菜单名称',
  'menu.form.pathPlaceholder': '请输入菜单路径',
  'menu.form.componentPlaceholder': '请输入组件路径',
  'menu.form.iconPlaceholder': '请输入图标名称',
  'menu.form.orderPlaceholder': '请输入排序号',
  'menu.form.submitAdd': '添加菜单',
  'menu.form.submitUpdate': '更新菜单',
  'menu.validation.nameRequired': '请输入菜单名称',
  'menu.validation.pathRequired': '请输入菜单路径',
  'menu.validation.componentRequired': '请输入组件路径',
  
  // 仪表板
  'dashboard.title': '数据概览',
  'dashboard.subtitle': '实时监控关键业务指标',
  'dashboard.trend': '内容营销趋势',
  'dashboard.trendSubtitle': '过去7天的数据变化',
  'dashboard.total': '总计',
  'dashboard.hotStores': '线上热门门店',
  'dashboard.contentRatio': '内容数据占比',

  // 占位提示
  'placeholder.productList': '商品列表功能开发中...',
  'placeholder.productCategory': '商品分类功能开发中...',
  'placeholder.productUpload': '批量导入功能开发中...（将集成大文件切片上传）',
  'placeholder.fileManage': '文件管理功能开发中...（将集成大文件切片上传、断点续传）',
  'placeholder.orderList': '订单列表功能开发中...（将支持PDF/Word/Excel导出）',
  'placeholder.orderRefund': '退款管理功能开发中...',
  'placeholder.menuManage': '菜单管理功能开发中...',
  'placeholder.permissionManage': '权限配置功能开发中...（将支持按钮级权限控制）',
  'placeholder.salesStats': '销售统计功能开发中...（将集成图表展示）',
  'placeholder.dataExport': '数据导出功能开发中...（将支持多格式导出）',
  'placeholder.documentList': '协同文档功能开发中...（将集成实时评论、版本历史、权限控制）',
  'placeholder.documentCollab': '在线协作编辑器开发中...（将集成Quill富文本编辑器与Socket.io实时协作）',
  'placeholder.userList': '用户管理功能开发中...（将提供用户画像、权限、批量导入等能力）',

  // 审计日志
  'auditLog.title': '审计日志',
  'auditLog.subtitle': '追踪用户关键操作，满足合规与安全审计需求',
  'auditLog.totalLogs': '总日志量',
  'auditLog.todayActions': '今日操作',
  'auditLog.activeUsers': '活跃用户',
  'auditLog.latestAction': '最近操作',
  'auditLog.latestNone': '--',
  'auditLog.keyword': '关键词',
  'auditLog.keywordPlaceholder': '搜索操作、模块、URL或用户',
  'auditLog.moduleFilter': '模块筛选',
  'auditLog.allModules': '全部模块',
  'auditLog.startDate': '开始日期',
  'auditLog.endDate': '结束日期',
  'auditLog.resetFilters': '清空筛选',
  'auditLog.refresh': '刷新数据',
  'auditLog.loading': '正在加载数据，请稍候...',
  'auditLog.empty': '暂无审计日志记录',
  'auditLog.table.time': '时间',
  'auditLog.table.user': '用户',
  'auditLog.table.module': '模块',
  'auditLog.table.action': '操作',
  'auditLog.table.detail': '详情',
  'auditLog.table.requestInfo': '请求信息',
  'auditLog.request.method': '方法',
  'auditLog.request.url': 'URL',
  'auditLog.request.ip': 'IP',
  'auditLog.pagination.perPage': '每页显示',
  'auditLog.pagination.summary': '条，当前第 {page}/{totalPages} 页，共 {total} 条记录',
  'auditLog.prev': '上一页',
  'auditLog.next': '下一页',
  'auditLog.moduleStatsTitle': '模块操作统计',
  'auditLog.moduleDefault': '通用模块',
  'auditLog.anonymousUser': '匿名用户',
  'auditLog.menuVisitAction': '访问菜单页面',
  'auditLog.menuVisitDetail': '用户访问了 {menu} 菜单',
  'auditLog.pageVisitAction': '访问审计日志页面',
  'auditLog.pageVisitDetail': '用户打开审计日志管理页面',
  
  // 主题
  'theme.light': '浅色主题',
  'theme.dark': '深色主题',
  'theme.system': '跟随系统',
  
  // 语言
  'language.zhCN': '简体中文',
  'language.enUS': 'English',
}

// 英文语言包
const enUSMessages: Record<string, string> = {
  // Common
  'common.save': 'Save',
  'common.cancel': 'Cancel',
  'common.delete': 'Delete',
  'common.edit': 'Edit',
  'common.create': 'Create',
  'common.search': 'Search',
  'common.reset': 'Reset',
  'common.confirm': 'Confirm',
  'common.loading': 'Loading...',
  'common.success': 'Success',
  'common.failed': 'Failed',
  'common.operation': 'Operation',
  'common.status': 'Status',
  'common.enable': 'Enable',
  'common.disable': 'Disable',
  'common.active': 'Active',
  'common.inactive': 'Inactive',
  'common.visible': 'Visible',
  'common.hidden': 'Hidden',
  'common.id': 'ID',
  'common.refresh': 'Refresh',
  'common.batchDelete': 'Batch Delete',
  'common.firstPage': 'First Page',
  'common.lastPage': 'Last Page',
  'common.prevPage': 'Previous',
  'common.nextPage': 'Next',
  'common.pageIndicator': 'Page {page}',
  'common.totalRecords': 'Total {count} records',
  'common.yes': 'Yes',
  'common.no': 'No',
  'common.unknownError': 'Unknown error',
  
  // Navigation
  'nav.dashboard': 'Dashboard',
  'nav.workplace': 'Workplace',
  'nav.document': 'Document',
  'nav.user': 'User Center',
  'nav.system': 'System Management',
  'nav.settings': 'System Settings',

  // Sidebar
  'sidebar.dashboard': 'Dashboard',
  'sidebar.product': 'Product Management',
  'sidebar.productList': 'Product List',
  'sidebar.productCategory': 'Product Category',
  'sidebar.productUpload': 'Bulk Import',
  'sidebar.order': 'Order Management',
  'sidebar.orderList': 'Order List',
  'sidebar.orderRefund': 'Refund Management',
  'sidebar.user': 'User Management',
  'sidebar.document': 'Document Collaboration',
  'sidebar.docList': 'Document List',
  'sidebar.docCollab': 'Online Collaboration',
  'sidebar.statistics': 'Analytics',
  'sidebar.salesStats': 'Sales Statistics',
  'sidebar.dataExport': 'Data Export',
  'sidebar.fileManage': 'File Management',
  'sidebar.fileList': 'File List',
  'sidebar.favorites': 'My Favorites',
  'sidebar.recycleBin': 'Recycle Bin',
  'sidebar.chat': 'Messenger',
  'sidebar.system': 'System Management',
  'sidebar.roleManage': 'Role Management',
  'sidebar.permissionManage': 'Permission Configuration',
  'sidebar.menuManage': 'Menu Management',
  'sidebar.auditLog': 'Audit Log',
  'sidebar.settings': 'System Settings',
  
  // System Settings
  'settings.title': 'System Settings',
  'settings.subtitle': 'Configure system parameters and feature options',
  'settings.basic': 'Basic Settings',
  'settings.email': 'Email Settings',
  'settings.security': 'Security Settings',
  'settings.storage': 'Storage Settings',
  'settings.notification': 'Notification Settings',
  'settings.systemName': 'System Name',
  'settings.systemLanguage': 'System Language',
  'settings.systemTimezone': 'Timezone',
  'settings.systemDescription': 'System Description',
  'settings.systemLogo': 'System Logo',
  'settings.smtpHost': 'SMTP Server',
  'settings.smtpPort': 'SMTP Port',
  'settings.smtpUser': 'SMTP Username',
  'settings.smtpPassword': 'SMTP Password',
  'settings.smtpFrom': 'Sender Email',
  'settings.smtpSsl': 'Enable SSL/TLS',
  'settings.securityHelper': 'Configure password policy and login security options',
  'settings.defaultSystemName': 'Universal Management System',
  'settings.defaultDescription': 'Enterprise management platform',
  'settings.systemNamePlaceholder': 'Enter system name',
  'settings.systemDescriptionPlaceholder': 'Enter system description',
  'settings.uploadLogo': 'Upload Logo',
  'settings.logoTip': 'Recommended size: 200x200px, PNG or JPG, up to 2MB',
  'settings.clearLogo': 'Remove Logo',
  'settings.logoTypeError': 'Please upload PNG or JPG images only',
  'settings.logoSizeError': 'Image size cannot exceed 2MB',
  'settings.logoReadError': 'Failed to read image, please retry',
  'settings.emailHelper': 'Used for sending system notification and verification emails',
  'settings.smtpPasswordPlaceholder': 'Enter SMTP password',
  'settings.testConnection': 'Test Connection',
  'settings.passwordPolicyTitle': 'Password Policy',
  'settings.loginSecurityTitle': 'Login Security',
  'settings.storageTypeLabel': 'Storage Type',
  'settings.storageLocal': 'Local Storage',
  'settings.storageOss': 'Aliyun OSS',
  'settings.storageS3': 'AWS S3',
  'settings.storageQiniu': 'Qiniu Cloud',
  'settings.notificationEmailDesc': 'Enable email notifications',
  'settings.notificationSmsDesc': 'Enable SMS notifications',
  'settings.notificationPushDesc': 'Enable browser push notifications',
  'settings.saveSuccess': 'Settings saved! System name and logo were updated in navigation and browser title',
  'settings.passwordMinLength': 'Minimum Password Length',
  'settings.passwordRequireUppercase': 'Require Uppercase',
  'settings.passwordRequireLowercase': 'Require Lowercase',
  'settings.passwordRequireNumber': 'Require Number',
  'settings.passwordRequireSpecial': 'Require Special Character',
  'settings.loginAttempts': 'Max Login Attempts',
  'settings.sessionTimeout': 'Session Timeout (minutes)',
  'settings.twoFactorAuth': 'Enable Two-Factor Authentication (2FA)',
  'settings.storageType': 'Storage Type',
  'settings.storagePath': 'Storage Path',
  'settings.maxFileSize': 'Max File Size (MB)',
  'settings.emailNotification': 'Email Notification',
  'settings.smsNotification': 'SMS Notification',
  'settings.pushNotification': 'Push Notification',
  
  // Role Management
  'role.title': 'Role Management',
  'role.subtitle': 'Manage system roles and permission assignments',
  'role.name': 'Role Name',
  'role.code': 'Role Code',
  'role.description': 'Role Description',
  'role.userCount': 'User Count',
  'role.permissionCount': 'Permission Count',
  'role.create': 'Create Role',
  'role.edit': 'Edit Role',
  'role.delete': 'Delete Role',
  'role.permissions': 'Permission Configuration',
  'role.codePlaceholder': 'Enter role code, e.g. admin',
  'role.descriptionPlaceholder': 'Enter role description',
  'role.wip': 'RBAC permission management is under development and will support full role/permission workflows soon.',
  'role.searchPlaceholder': 'Search role name...',
  'role.batchDelete': 'Batch Delete',
  'role.batchDeleteWithCount': 'Batch Delete ({count})',
  'role.empty': 'No role data available',
  'role.table.id': 'ID',
  'role.table.name': 'Role Name',
  'role.table.age': 'Age',
  'role.table.gender': 'Gender',
  'role.table.status': 'Status',
  'role.table.createTime': 'Created At',
  'role.table.updateTime': 'Updated At',
  'role.table.actions': 'Actions',
  'role.gender.male': 'Male',
  'role.gender.female': 'Female',
  'role.status.enabled': 'Enabled',
  'role.status.disabled': 'Disabled',
  'role.confirmDelete': 'Are you sure you want to delete this role?',
  'role.addSuccess': 'Role created successfully',
  'role.addFailed': 'Failed to create role. Please try again later.',
  'role.updateSuccess': 'Role updated successfully',
  'role.updateFailed': 'Failed to update role. Please try again later.',
  'role.deleteSuccess': 'Role deleted successfully',
  'role.deleteFailed': 'Failed to delete role. Please try again later.',
  'role.batchDeleteEmpty': 'Please select at least one role to delete',
  'role.batchDeleteConfirm': 'Delete selected {count} roles?',
  'role.batchDeleteSuccess': 'Batch delete succeeded',
  'role.batchDeleteFailed': 'Batch delete failed. Please try again later.',
  'role.namePlaceholder': 'Enter role name',
  'role.nameRequired': 'Please enter a role name',
  'role.agePlaceholder': 'Enter age',
  'role.ageInvalid': 'Please enter a valid age',
  'role.modal.createTitle': 'Create Role',
  'role.modal.editTitle': 'Edit Role',

  // File Management
  'file.manage.title': 'File Management',
  'file.manage.subtitle': 'Manage uploaded files (supports large file chunk upload)',

  // Product Module
  'product.list.title': 'Product List',
  'product.list.subtitle': 'Manage all product information',
  'product.category.title': 'Product Category',
  'product.category.subtitle': 'Manage product category information',
  'product.upload.title': 'Bulk Import',
  'product.upload.subtitle': 'Import product data in bulk (large file support)',

  // Order Module
  'order.list.title': 'Order List',
  'order.list.subtitle': 'Manage customer orders and fulfillment',
  'order.list.pageTitle': 'Order List',
  'order.list.pageDescription': 'Manage all order information',
  'order.list.addOrder': 'Add Order',
  'order.list.exportExcel': 'Export Excel',
  'order.list.exportImage': 'Export Image',
  'order.list.exportWord': 'Export Word',
  'order.list.exporting': 'Exporting...',
  'order.list.exportData': 'Export Data',
  'order.list.tabs.all': 'All Orders',
  'order.list.tabs.pending': 'Pending',
  'order.list.tabs.shipped': 'Shipped',
  'order.list.tabs.completed': 'Completed',
  'order.list.table.orderId': 'Order ID',
  'order.list.table.productName': 'Product Name',
  'order.list.table.productPrice': 'Product Price',
  'order.list.table.quantity': 'Quantity',
  'order.list.table.totalPrice': 'Total Price',
  'order.list.table.customerName': 'Customer Name',
  'order.list.table.customerPhone': 'Customer Phone',
  'order.list.table.address': 'Shipping Address',
  'order.list.table.status': 'Order Status',
  'order.list.table.createdAt': 'Created At',
  'order.list.table.actions': 'Actions',
  'order.list.status.pending': 'Pending',
  'order.list.status.shipped': 'Shipped',
  'order.list.status.completed': 'Completed',
  'order.list.status.cancelled': 'Cancelled',
  'order.list.empty': 'No orders available',
  'order.list.pagination': 'Total {total} records',
  'order.list.modal.title': 'Add Order',
  'order.list.modal.product': 'Select Product',
  'order.list.modal.productPlaceholder': 'Select a product',
  'order.list.modal.quantity': 'Quantity',
  'order.list.modal.quantityPlaceholder': 'Enter purchase quantity',
  'order.list.modal.quantityRequired': 'Please enter purchase quantity',
  'order.list.modal.quantityInvalid': 'Quantity must be greater than 0',
  'order.list.modal.customerName': 'Customer Name',
  'order.list.modal.customerNamePlaceholder': 'Enter customer name',
  'order.list.modal.customerNameRequired': 'Please enter customer name',
  'order.list.modal.customerPhone': 'Customer Phone',
  'order.list.modal.customerPhonePlaceholder': 'Enter customer phone',
  'order.list.modal.customerPhoneRequired': 'Please enter customer phone',
  'order.list.modal.customerPhoneInvalid': 'Please enter a valid phone number',
  'order.list.modal.address': 'Shipping Address',
  'order.list.modal.addressPlaceholder': 'Enter shipping address',
  'order.list.modal.addressRequired': 'Please enter shipping address',
  'order.list.modal.ok': 'Confirm',
  'order.list.modal.cancel': 'Cancel',
  'order.list.modal.stock': 'Stock',
  'order.list.messages.fetchProductsFailed': 'Failed to fetch product list',
  'order.list.messages.fetchProductsFallback': '{message}, using mock product data',
  'order.list.messages.fetchOrdersFailed': 'Failed to fetch order list, please check the backend service',
  'order.list.messages.fetchOrdersFallback': '{message}, using mock order data',
  'order.list.messages.inventoryInsufficient': 'Insufficient stock, current stock: {stock}',
  'order.list.messages.addSuccess': 'Order created successfully',
  'order.list.messages.addFailed': 'Failed to create order',
  'order.list.messages.addFailedNetwork': 'Failed to create order, please check your network connection',
  'order.list.messages.statusUpdateSuccess': 'Order status updated',
  'order.list.messages.statusUpdateFailed': 'Failed to update order status',
  'order.list.messages.statusUpdateFailedNetwork': 'Failed to update order status, please check your network connection',
  'order.list.messages.exportExcelSuccess': 'Excel exported successfully',
  'order.list.messages.exportExcelFailed': 'Failed to export Excel',
  'order.list.messages.exportImageSuccess': 'Image exported successfully',
  'order.list.messages.exportImageFailed': 'Failed to export image',
  'order.list.messages.exportWordSuccess': 'Word exported successfully',
  'order.list.messages.exportWordFailed': 'Failed to export Word',
  'order.list.messages.unknownProduct': 'Unknown Product',
  'order.list.messages.generatedAt': 'Generated at: {time}',
  'order.list.delete.confirmTitle': 'Confirm Deletion',
  'order.list.delete.confirmContent': 'Are you sure you want to delete this order?',
  'order.list.delete.success': 'Order deleted successfully',
  'order.list.delete.failed': 'Failed to delete order',

  // Order refund module
  'order.refund.title': 'Refund Management',
  'order.refund.subtitle': 'Manage refunds for cancelled orders',
  'order.refund.refresh': 'Refresh List',
  'order.refund.exportExcel': 'Export Excel',
  'order.refund.exportImage': 'Export Image',
  'order.refund.exportWord': 'Export Word',
  'order.refund.exporting': 'Exporting...',
  'order.refund.exportData': 'Export Data',
  'order.refund.tabs.pending': 'Pending Refund',
  'order.refund.tabs.processed': 'Processed Refund',
  'order.refund.table.orderId': 'Order ID',
  'order.refund.table.productName': 'Product Name',
  'order.refund.table.productPrice': 'Product Price',
  'order.refund.table.quantity': 'Quantity',
  'order.refund.table.totalPrice': 'Total Price',
  'order.refund.table.customerName': 'Customer Name',
  'order.refund.table.customerPhone': 'Customer Phone',
  'order.refund.table.address': 'Shipping Address',
  'order.refund.table.createdAt': 'Created At',
  'order.refund.table.status': 'Refund Status',
  'order.refund.table.actions': 'Actions',
  'order.refund.status.pending': 'Pending Refund',
  'order.refund.status.processed': 'Processed Refund',
  'order.refund.status.unprocessedCount': 'Total {count} pending refund orders',
  'order.refund.status.processedCount': 'Total {count} processed refund orders',
  'order.refund.empty.pending': 'No pending refund orders',
  'order.refund.empty.processed': 'No processed refund orders',
  'order.refund.actions.processRefund': 'Process Refund',
  'order.refund.actions.processed': 'Processed',
  'order.refund.actions.delete': 'Delete',
  'order.refund.confirm.title': 'Confirm Refund',
  'order.refund.confirm.content': 'Process refund for this order? This action cannot be undone.',
  'order.refund.confirm.ok': 'Confirm',
  'order.refund.confirm.cancel': 'Cancel',
  'order.refund.messages.refundSuccess': 'Refund processed successfully',
  'order.refund.messages.refundFailed': 'Failed to process refund',
  'order.refund.messages.refundFailedNetwork': 'Refund failed, please check your network connection',
  'order.refund.messages.fetchFailed': 'Failed to fetch refund orders',
  'order.refund.messages.deleteSuccess': 'Order deleted successfully',
  'order.refund.messages.deleteFailed': 'Failed to delete order',
  'order.refund.messages.deleteFailedNetwork': 'Failed to delete order, please check your network connection',
  'order.refund.messages.exportExcelSuccess': 'Excel exported successfully',
  'order.refund.messages.exportExcelFailed': 'Failed to export Excel',
  'order.refund.messages.exportImageSuccess': 'Image exported successfully',
  'order.refund.messages.exportImageFailed': 'Failed to export image',
  'order.refund.messages.exportWordSuccess': 'Word exported successfully',
  'order.refund.messages.exportWordFailed': 'Failed to export Word',
  'order.refund.messages.generatedAt': 'Generated at: {time}',
  'order.refund.messages.unknownProduct': 'Unknown Product',

  // Statistics Module
  'statistics.sales.title': 'Sales Statistics',
  'statistics.sales.subtitle': 'Sales analytics and insights',
  'statistics.export.title': 'Data Export',
  'statistics.export.subtitle': 'Export reports in PDF / Word / Excel',

  // Document Module
  'document.list.title': 'Document Collaboration',
  'document.list.subtitle': 'Manage collaborative documents across product, campaign, and knowledge base scenarios',
  'document.collab.title': 'Realtime Collaborative Editor',
  'document.collab.subtitle': 'Realtime editing powered by WebSocket and conflict resolution algorithms',

  // User Module
  'user.list.title': 'User Management',
  'user.list.subtitle': 'Manage ecommerce user profiles and permissions',
  
  // Permission Management
  'permission.title': 'Permission Management',
  'permission.subtitle': 'Configure system permissions and access control',
  'permission.name': 'Permission Name',
  'permission.code': 'Permission Code',
  'permission.type': 'Permission Type',
  'permission.group': 'Permission Group',
  'permission.description': 'Permission Description',
  'permission.create': 'Create Permission',
  'permission.edit': 'Edit Permission',
  'permission.delete': 'Delete Permission',
  'permission.typeMenu': 'Menu Permission',
  'permission.typeButton': 'Button Permission',
  'permission.typeApi': 'API Permission',
  'permission.searchPlaceholder': 'Enter role name',
  'permission.refresh': 'Refresh',
  'permission.batchDelete': 'Batch Delete',
  'permission.batchDeleteWithCount': 'Batch Delete ({count})',
  'permission.add': 'Add Permission',
  'permission.deleteConfirm': 'Are you sure you want to delete this permission record?',
  'permission.batchDeleteConfirm': 'Delete selected {count} permission records?',
  'permission.batchDeleteEmpty': 'Please select permission records to delete',
  'permission.addSuccess': 'Permission added successfully',
  'permission.updateSuccess': 'Permission updated successfully',
  'permission.deleteSuccess': 'Deleted successfully',
  'permission.deleteFailed': 'Delete failed: {error}',
  'permission.batchDeleteSuccess': 'Batch delete succeeded',
  'permission.batchDeleteFailed': 'Batch delete failed: {error}',
  'permission.fetchError': 'Failed to load data: {error}',
  'permission.operationFailed': 'Operation failed: {error}',
  'permission.scopePlaceholder': 'Enter permission scope, separated by commas',
  'permission.scenePlaceholder': 'Enter applicable scenario',
  'permission.total': 'Total {count} records',
  'permission.none': 'No permissions',
  'permission.validation.roleNameRequired': 'Role name is required',
  'permission.validation.scopeRequired': 'Permission scope is required',
  'permission.validation.sceneRequired': 'Applicable scenario is required',
  'permission.loadingTip': 'Loading permission data...',
  'permission.table.id': 'Permission ID',
  'permission.table.roleName': 'Role Name',
  'permission.table.scope': 'Permission Scope',
  'permission.table.scene': 'Applicable Scenario',
  'permission.table.createTime': 'Created At',
  'permission.table.actions': 'Actions',
  'permission.emptyTitle': 'No permission data',
  'permission.emptySubtitle': 'There are no permission records yet. Click the button below to add a new permission.',
  'permission.editAction': 'Edit',
  'permission.deleteAction': 'Delete',
  
  // Menu Management
  'menu.title': 'Menu Management',
  'menu.subtitle': 'Manage system menu structure and permission configuration',
  'menu.name': 'Menu Name',
  'menu.path': 'Menu Path',
  'menu.icon': 'Menu Icon',
  'menu.sort': 'Sort',
  'menu.parent': 'Parent Menu',
  'menu.type': 'Menu Type',
  'menu.permission': 'Permission Code',
  'menu.visible': 'Show Menu',
  'menu.create': 'Create Menu',
  'menu.edit': 'Edit Menu',
  'menu.delete': 'Delete Menu',
  'menu.addChild': 'Add Child Menu',
  'menu.add': 'Add Menu',
  'menu.export': 'Export Menu',
  'menu.batchDelete': 'Batch Delete',
  'menu.batchDeleteWithCount': 'Batch Delete ({count})',
  'menu.searchPlaceholder': 'Search menu name or path',
  'menu.loading': 'Loading...',
  'menu.empty': 'No menu data available',
  'menu.total': 'Total {count} records',
  'menu.table.id': 'Menu ID',
  'menu.table.name': 'Menu Name',
  'menu.table.path': 'Path',
  'menu.table.parent': 'Parent Menu',
  'menu.table.level': 'Level',
  'menu.table.order': 'Order',
  'menu.table.hidden': 'Hidden',
  'menu.table.status': 'Status',
  'menu.table.createTime': 'Created At',
  'menu.table.actions': 'Actions',
  'menu.boolean.yes': 'Yes',
  'menu.boolean.no': 'No',
  'menu.parent.top': 'Top-level Menu',
  'menu.parent.unknown': 'Unknown Parent Menu',
  'menu.toggleEnable': 'Enable',
  'menu.toggleDisable': 'Disable',
  'menu.deleteConfirm': 'Are you sure you want to delete this menu? This action cannot be undone!',
  'menu.deleteSuccess': 'Menu deleted successfully',
  'menu.deleteFailed': 'Failed to delete menu: {error}',
  'menu.addSuccess': 'Menu added successfully',
  'menu.addFailed': 'Failed to save menu: {error}',
  'menu.updateSuccess': 'Menu updated successfully',
  'menu.updateFailed': 'Failed to save menu: {error}',
  'menu.toggleSuccess': 'Menu status toggled',
  'menu.toggleFailed': 'Failed to toggle menu status: {error}',
  'menu.batchDeleteEmpty': 'Please select menus to delete',
  'menu.batchDeleteConfirm': 'Delete selected {count} menus? This action cannot be undone!',
  'menu.batchDeleteSuccess': 'Batch delete succeeded',
  'menu.batchDeleteFailed': 'Batch delete failed: {error}',
  'menu.exportSuccess': 'Menu data exported successfully',
  'menu.exportFailed': 'Failed to export menu data: {error}',
  'menu.fetchFailed': 'Failed to load menu list: {error}',
  'menu.searchFailed': 'Failed to search menus: {error}',
  'menu.form.nameLabel': 'Menu Name *',
  'menu.form.pathLabel': 'Menu Path *',
  'menu.form.componentLabel': 'Component Path *',
  'menu.form.iconLabel': 'Menu Icon',
  'menu.form.parentLabel': 'Parent Menu',
  'menu.form.orderLabel': 'Sort',
  'menu.form.hiddenLabel': 'Hide Menu',
  'menu.form.statusLabel': 'Status',
  'menu.form.levelInfo': 'Current menu level: {level}',
  'menu.form.namePlaceholder': 'Enter menu name',
  'menu.form.pathPlaceholder': 'Enter menu path',
  'menu.form.componentPlaceholder': 'Enter component path',
  'menu.form.iconPlaceholder': 'Enter icon name',
  'menu.form.orderPlaceholder': 'Enter sort number',
  'menu.form.submitAdd': 'Add Menu',
  'menu.form.submitUpdate': 'Update Menu',
  'menu.validation.nameRequired': 'Please enter a menu name',
  'menu.validation.pathRequired': 'Please enter a menu path',
  'menu.validation.componentRequired': 'Please enter a component path',
  
  // Dashboard
  'dashboard.title': 'Dashboard',
  'dashboard.subtitle': 'Real-time monitoring of key business metrics',
  'dashboard.trend': 'Content Marketing Trend',
  'dashboard.trendSubtitle': 'Data changes over the past 7 days',
  'dashboard.total': 'Total',
  'dashboard.hotStores': 'Hot Online Stores',
  'dashboard.contentRatio': 'Content Data Ratio',

  // Placeholder
  'placeholder.productList': 'Product list feature is under development...',
  'placeholder.productCategory': 'Product category feature is under development...',
  'placeholder.productUpload': 'Bulk import is under development (large file chunk upload coming soon).',
  'placeholder.fileManage': 'File management is under development (chunk upload & resume support coming soon).',
  'placeholder.orderList': 'Order list feature is under development (PDF / Word / Excel exports coming soon).',
  'placeholder.orderRefund': 'Refund workflow is under development...',
  'placeholder.menuManage': 'Menu management feature is under development...',
  'placeholder.permissionManage': 'Permission configuration is under development (button-level access coming soon)',
  'placeholder.salesStats': 'Sales analytics is under development (charts will be available soon)',
  'placeholder.dataExport': 'Data export is under development (multi-format export coming soon)',
  'placeholder.documentList': 'Collaborative document management is under development (real-time comments, version history, permissions).',
  'placeholder.documentCollab': 'Realtime collaborative editor is under development (Quill editor + Socket.io integration).',
  'placeholder.userList': 'User management is under development (user insights, permissions and batch import).',

  // Audit Log
  'auditLog.title': 'Audit Log',
  'auditLog.subtitle': 'Track critical user actions for compliance and security needs',
  'auditLog.totalLogs': 'Total Logs',
  'auditLog.todayActions': 'Today\'s Actions',
  'auditLog.activeUsers': 'Active Users',
  'auditLog.latestAction': 'Latest Action',
  'auditLog.latestNone': '--',
  'auditLog.keyword': 'Keyword',
  'auditLog.keywordPlaceholder': 'Search actions, modules, URL or user',
  'auditLog.moduleFilter': 'Module Filter',
  'auditLog.allModules': 'All Modules',
  'auditLog.startDate': 'Start Date',
  'auditLog.endDate': 'End Date',
  'auditLog.resetFilters': 'Clear Filters',
  'auditLog.refresh': 'Refresh Data',
  'auditLog.loading': 'Loading, please wait...',
  'auditLog.empty': 'No audit log records yet',
  'auditLog.table.time': 'Time',
  'auditLog.table.user': 'User',
  'auditLog.table.module': 'Module',
  'auditLog.table.action': 'Action',
  'auditLog.table.detail': 'Detail',
  'auditLog.table.requestInfo': 'Request Info',
  'auditLog.request.method': 'Method',
  'auditLog.request.url': 'URL',
  'auditLog.request.ip': 'IP',
  'auditLog.pagination.perPage': 'Per Page',
  'auditLog.pagination.summary': 'records, page {page} of {totalPages}, {total} records total',
  'auditLog.prev': 'Previous',
  'auditLog.next': 'Next',
  'auditLog.moduleStatsTitle': 'Module Activity Overview',
  'auditLog.moduleDefault': 'General Module',
  'auditLog.anonymousUser': 'Anonymous User',
  'auditLog.menuVisitAction': 'Navigate Menu',
  'auditLog.menuVisitDetail': 'User navigated to {menu}',
  'auditLog.pageVisitAction': 'View Audit Log Page',
  'auditLog.pageVisitDetail': 'User opened the audit log page',
  
  // Theme
  'theme.light': 'Light Theme',
  'theme.dark': 'Dark Theme',
  'theme.system': 'Follow System',
  
  // Language
  'language.zhCN': '简体中文',
  'language.enUS': 'English',
}

// 语言包映射
const messages: Record<Language, Record<string, string>> = {
  'zh-CN': zhCNMessages,
  'en-US': enUSMessages,
}

class I18n {
  private locale: Language = 'zh-CN'
  private listeners: Set<() => void> = new Set()

  constructor() {
    // 从 localStorage 读取语言设置
    const savedLocale = localStorage.getItem('i18n-locale') as Language
    if (savedLocale && (savedLocale === 'zh-CN' || savedLocale === 'en-US')) {
      this.locale = savedLocale
    } else {
      // 根据浏览器语言自动设置
      const browserLang = navigator.language || 'zh-CN'
      this.locale = browserLang.startsWith('zh') ? 'zh-CN' : 'en-US'
    }
  }

  // 设置语言
  setLocale(locale: Language) {
    this.locale = locale
    localStorage.setItem('i18n-locale', locale)
    this.notifyListeners()
  }

  // 获取当前语言
  getLocale(): Language {
    return this.locale
  }

  // 翻译函数
  t(key: string, params?: Record<string, string | number>): string {
    const message = messages[this.locale][key] || key
    
    if (params) {
      return message.replace(/\{(\w+)\}/g, (match, paramKey) => {
        return params[paramKey]?.toString() || match
      })
    }
    
    return message
  }

  // 订阅语言变化
  subscribe(listener: () => void) {
    this.listeners.add(listener)
    return () => {
      this.listeners.delete(listener)
    }
  }

  // 通知所有监听器
  private notifyListeners() {
    this.listeners.forEach(listener => listener())
  }
}

export const i18n = new I18n()

// React Hook
export function useTranslation() {
  const [, forceUpdate] = React.useReducer(x => x + 1, 0)

  React.useEffect(() => {
    const unsubscribe = i18n.subscribe(() => {
      forceUpdate()
    })
    return unsubscribe
  }, [])

  return {
    t: i18n.t.bind(i18n),
    locale: i18n.getLocale(),
    setLocale: i18n.setLocale.bind(i18n),
  }
}

